//
//  KKFeedBackController.m
//  DoMi
//
//  Created by 康凯 on 2016/11/16.
//  Copyright © 2016年 kk. All rights reserved.
//

#import "KKFeedBackController.h"
#import "KKMyHttp.h"

@interface KKFeedBackController ()<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *content;
@property (weak, nonatomic) IBOutlet UITextField *contact;

@end

@implementation KKFeedBackController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"意见反馈";
    self.content.delegate=self;
}

-(void)textViewDidBeginEditing:(UITextView *)textView{
    if([textView.text isEqualToString:@"把您使用过程的感受告诉我们吧"]){
        textView.text=@"";
        textView.textColor=[UIColor blackColor];
    }
}
-(void)textViewDidEndEditing:(UITextView *)textView{
    if(textView.text.length < 1){
        textView.text = @"把您使用过程的感受告诉我们吧";
        textView.textColor = [UIColor grayColor];
    }
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
- (IBAction)commitClick:(id)sender {
    if([self.content.text isEqualToString:@"把您使用过程的感受告诉我们吧"]){
        [self toast:@"请输入反馈内容"];
        return;
    }
    if([KKAppUtils isEmptyString:self.contact.text]){
        [self toast:@"请输入联系方式"];
        return;
    }
    [self commitFeedBack];
}


#pragma mark 接口--提交反馈
-(void)commitFeedBack{
    NSDictionary *params=@{UID_KEY:UID,TOKEN_KEY:TOKEN,@"contact":self.contact.text,@"content":self.content.text};
    [KKMyHttp commitFeedBack:params success:^(id data) {
        [self toast:@"提交成功"];
        self.content.text=@"";
        self.contact.text=@"";
    } failure:^(NSError *error) {
        
    }];
}

@end
